# Huawei Technologies Co.,Ltd.

set(SPREAD_PRIMITIVES_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/spread_primitives.txt)
set(SPREAD_PRIMITIVES_BIN ${CMAKE_CURRENT_BINARY_DIR}/spread_primitives.abc)
set(SPREAD_PRIMITIVES_JS ${CMAKE_CURRENT_SOURCE_DIR}/spread_primitives.js)
set(SPREAD_PRIMITIVES_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${CMAKE_BINARY_DIR}/pandastdlib/arkstdlib.abc --compiler-enable-jit=false --run-gc-in-place --load-runtimes \"ecmascript\" ${SPREAD_PRIMITIVES_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${SPREAD_PRIMITIVES_OUTPUT}
    COMMENT "running javascript spread_primitives testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${SPREAD_PRIMITIVES_JS}  --output ${SPREAD_PRIMITIVES_BIN}
    COMMAND rm -f ${SPREAD_PRIMITIVES_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} 2>&1 > ${SPREAD_PRIMITIVES_OUTPUT}
    COMMAND bash ${SPREAD_PRIMITIVES_VERIFY} ${SPREAD_PRIMITIVES_OUTPUT}
)
add_custom_target(spread_primitives
    DEPENDS ${SPREAD_PRIMITIVES_OUTPUT} ${SPREAD_PRIMITIVES_VERIFY}
)
add_dependencies(spread_primitives es2panda ark)
add_dependencies(ecmascript_common_tests spread_primitives)
